
class Parent{
    constructor(){
        this.name = 'name';
    }
    getName(){
        console.log(this.getAge());
        return this.name;
    }
}
class Child extends Parent{
    constructor(){
        super();
        this.name = 'name';
        this.age = 'age';
    }
    getAge(){
        return this.age;
    }
}
let child = new Child();
child.getName(); //age
//如果创建的是子类的实例，那么只会有一个子类的实例，不存在父类的实例
let parent = new Parent();
parent.getName(); //TypeError: this.getAge is not a function

